package org.poptest.processor.phase;

import org.poptest.model.Context;
import org.poptest.processor.Phase;
import org.poptest.processor.Processor;
import org.poptest.processor.annotation.AnnotationProcessor;
import org.poptest.util.AssertInternal;

/**
 * @author Alan Roche
 *         Date: 13/02/11
 *         Time: 15:28
 */
public abstract class PhaseProcessor implements Processor {
    private final AnnotationProcessor[] annotationProcessors;
    private final Phase phase;

    protected PhaseProcessor(final Phase phase, final AnnotationProcessor... annotationProcessors) {
        this.annotationProcessors = annotationProcessors;
        AssertInternal.noneNull(annotationProcessors);
        this.phase = phase;
    }

    public Processor[] getAnnotationProcessors() {
        return annotationProcessors;
    }

    public final void process(final Context context) {
        context.setPhase(this.phase);
        doProcess(context);
    }

    protected abstract void doProcess(final Context context);
}
